package com.dc.refactoring._3_重新组织数据._14_ReplaceSubClassWithFields.step4;

/**
 * Description: Person 人 抽象类
 * @author: gdc
 * @date: 2020/12/4
 * @version 1.0
 */
public class Person {

    private final boolean isMale;
    private final char code;

    protected Person(boolean isMale, char code) {
        this.isMale = isMale;
        this.code = code;
    }

    static Person createMale(){
        // 【7】将子类构造函数内联到超类的工厂函数中
        return new Person(true, 'M');
    }

    static Person createFemale(){
        return new Person(false, 'F');
    }

    boolean isMale(){
        return isMale;
    }

    char getCode(){
        return code;
    }

}


// 【8】删除子类